package Thread.Demo4StaticProxy;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author wangzhipeng
 * @Date 2020-08-10 2:40 下午
 * @Description 静态代理模式
 */
public class StaticProxy {
    public static void main(String[] args) {
        WeddingCompany weddingCompany = new WeddingCompany(new You());
        weddingCompany.HappyMarry();
    }
}

interface Marry{
    void HappyMarry();
}

//真实角色，你去结婚
class You implements Marry{

    public void HappyMarry() {
        System.out.println("秦老师要结婚了，好开心");
    }
}

//代理角色，帮助你结婚
class WeddingCompany implements Marry{

    private Marry target;

    public WeddingCompany(Marry target) {
        this.target = target;
    }

    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }

    private void after() {
        System.out.println("结婚之前，布置现场");
    }

    private void before() {
        System.out.println("结婚之后，很痛苦");
    }
}
